/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.data.dao.bean;


import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class CompositeKey {
    List<IKeyed> keys=new ArrayList();

    public CompositeKey() {
    }

    public static CompositeKey instance(final String key1,final String key2) {
        CompositeKey c=new CompositeKey();
        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key1;
            }
        });
        
        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key2;
            }
        });
        return c;
    }

    public static CompositeKey instance(final String key1,final String key2,final String key3) {
        CompositeKey c=new CompositeKey();
        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key1;
            }
        });

        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key2;
            }
        });

        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key3;
            }
        });

        return c;
    }

    public static CompositeKey instance(final String key1,final int key2) {
        CompositeKey c=new CompositeKey();
        c.addKey(new IKeyed<String>(){
            public String getKey() {
                return key1;
            }
        });

        c.addKey(new IKeyed<Integer>(){
            public Integer getKey() {
                return key2;
            }
        });
        return c;
    }



    public void  addKey(IKeyed key){
        keys.add(key);
    }

    public void remove(IKeyed key){
        keys.remove(key);
    }

    public void remove(int ind){
        keys.remove(ind);
    }

    public IKeyed getKey(int ind){
        return keys.get(ind);
    }

    public int size(){
        return keys.size();
    }
}
